 #!/usr/bin/python

"""
SMK license key server
"""
from __future__ import absolute_import, print_function, division

import cherrypy
import random

from smk.lks.resources.license import *


def main():

    random.seed()

    conf = {
        'global': {
            'server.socket_host': '127.0.0.1',
            'server.socket_port': 8080
        },
        '/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher()
        }
    }

    class Root(object):
        def handle_error():
            cherrypy.response.status = 500
            cherrypy.response.body = ["Internal server error"]

        def error_403(status, message, traceback, version):
            return message

        _cp_config = {
            'request.error_response': handle_error,
            'error_page.403': error_403
        }

    root = Root()
    root.lkm = LicenseManager()

    cherrypy.quickstart(root, '/', conf)
